import {request, requestRunResult, requestSubmitCode} from "@/network/request";

export function getProblemSet() {
    return request({
        url: '/problems'
    })
}

export function getProblem(name) {
    return request({
        url: '/problems/' + name
    })
}

export function getProblemCode(name) {
    return request({
        url: '/getProblemCode',
        params: {
            name: name
        }
    })
}

export function submitCodeToServer(problemId, language, code) {
    return requestSubmitCode({
        url: '/solutions',
        method: 'post',
        data: {
            problemId: problemId,
            language: language,
            code: code
        },
        headers: {
            'Content-Type': 'application/json;charset=utf-8'
        }
    })
}

export function getRunResultFromServer(solutionID) {
    return requestRunResult({
        url: '/solutions/' + solutionID,
        method: 'get'
    })
}
